import path from 'path'

const ignores = [
  '<rootDir>/node_modules/',
  '<rootDir>/build/',
  '<rootDir>/scripts/',
  '<rootDir>/api/',
  '<rootDir>/test/setup.js',
  '<rootDir>/test/polyfill.js',
  '<rootDir>/test/helpers/',
  '__mocks__',
]

const jestConfig = {
  bail: true,
  testEnvironment: 'jsdom',
  // cacheDirectory: './node_modules/.cache',
  // collectCoverageFrom: ['src/**/*.js'],

  testRegex: 'test/.*\\.jsx?$',
  testPathIgnorePatterns: [...ignores],

  coveragePathIgnorePatterns: [...ignores, '<rootDir>/src/shared/utils/url/'],
  coverageThreshold: {
    global: {
      branches: 90,
      functions: 90,
      lines: 90,
      statements: 90,
    },
  },
  moduleFileExtensions: ['', 'json', 'js', 'jsx', 'less'],
  modulePaths: ['<rootDir>/src', '<rootDir>'],
  moduleNameMapper: {
    '^import?': path.join(__dirname, './jest.importMock.js'),
    '\\.(css|less|gif|jpg|jpeg|png)$': path.join(
      __dirname,
      './jest.styleMock.js',
    ),
  },
  setupFiles: ['<rootDir>/test/setup.js'],
  transformIgnorePatterns: [
    '<rootDir>/node_modules/(?!(react-aaui|tempest\\.js)/)',
    'babel-runtime',
  ],
}

export default jestConfig
